package com.yuexunit.operationman.nbsy.module.Patients.presenter.impl;

import com.yuexunit.operationman.nbsy.module.OperationBeforeAndAfter.bean.BeforeAndAfterBean;
import com.yuexunit.operationman.nbsy.module.Patients.model.IPatientModel;
import com.yuexunit.operationman.nbsy.module.Patients.presenter.IPatientPresenter;
import com.yuexunit.operationman.nbsy.module.Patients.ui.view.IPatientView;

import java.util.ArrayList;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action0;
import rx.schedulers.Schedulers;

/**
 * Created by Administrator on 2018/1/26 0026.
 */

public class PatientPresenter implements IPatientPresenter{
    private IPatientModel mModel;
    private IPatientView mView;

    public PatientPresenter(IPatientView view, IPatientModel model){
        mModel=model;
        mView=view;
    }


    @Override
    public void getPatientList() {
        mModel.getPatientList()
                .subscribeOn(Schedulers.io())
                .doOnSubscribe(new Action0() {
                    @Override
                    public void call() {
//                        log.info("UserPresenter_doInLogin_SHOW_DIALOG");
//                        mView.(AppConfig.SHOW_DIALOG);
                    }
                })
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<ArrayList<BeforeAndAfterBean.ObjectEntity>>() {
                    @Override
                    public void onCompleted() {
//                        mView.loadingDialogStatus(AppConfig.DISMISS_DIALOG);
                    }

                    @Override
                    public void onError(Throwable e) {
//                        mView.loadingDialogStatus(AppConfig.DISMISS_DIALOG);
                    }

                    @Override
                    public void onNext(ArrayList<BeforeAndAfterBean.ObjectEntity> objectEntityArrayList) {
                        mView.getPatinetList(objectEntityArrayList);
                    }
                });
    }
}
